package org.road0329.tools.proto_parse_tool.enums;

/**
 * 充电桩远程命令
 */
public enum PileCmdEnum {
    /**
     * 充电命令
     */
    AUTH(1, "鉴权下行"),
    STOP_CHARGE(2, "停止充电"),

    /**
     * 参数命令
     */
    PRICE_SET(11, "计费模型下发"),
    ONLINE_UPDATE(12, "在线升级"),
    PILE_NO_SET(13, "桩号设置"),
    PILE_SERVER_SET(14, "服务器设置"),
    PILE_NETWORK_SET(15, "桩体联网设置"),
    PILE_QR_CODE_SET(16, "二维码设置"),

    PILE_PARAM_CALL(31, "桩体参数查询"),
    PILE_PWD_SECRET_KEY_CALL(32, "密码秘钥查询");

    private final int value;
    private final String text;

    private PileCmdEnum(int value, String text) {
        this.value = value;
        this.text = text;
    }

    public int getValue() {
        return value;
    }

    public Short getShortValue() {
        Integer obj = value;
        return obj.shortValue();
    }

    public String getText() {
        return text;
    }

    public static String getText(int value) {
        PileCmdEnum task = getEnumByValue(value);
        return task == null ? "" : task.getText();

    }

    /**
     * 通过传入的字符串匹配枚举，传入值
     */
    public static PileCmdEnum getEnumByValue(int value) {
        for (PileCmdEnum record : PileCmdEnum.values()) {
            if (value == record.getValue()) {
                return record;
            }
        }
        return null;
    }
}
